<%@ page contentType="text/html;charset=UTF-8" language="java" %> 
<%@ page import="org.wso2.carbon.registry.custom.dia.ui.utils.GetDocumentUtil" %>
<%@ page import="org.wso2.carbon.registry.common.utils.RegistryUtil" %>
<%@ page import="org.wso2.carbon.registry.common.ui.UIException" %> 
<%@ page import="org.wso2.carbon.registry.custom.dia.ui.beans.xsd.ResourceTreeEntryBean" %>

<%
    //String cPath = RegistryUtil.getPath(request);
    String cPath = "/";
    String[] treeChildren;
    ResourceTreeEntryBean bean;
    try {
        GetDocumentUtil getDocumentUtil = new GetDocumentUtil(config, session);
        bean = getDocumentUtil.getResourceTreeEntry(cPath, config, session); 
        System.out.println(cPath);
        
        treeChildren = bean.getChildren();
        if(treeChildren == null) throw new UIException("tree can not retrieved.");
    } catch (UIException e) {
        System.out.println("Error in retrieving details.");
        %>Error occured while retrieving Tree details<%
        return;
    }
    //out.print(treeChildren.length+"<h1>sdddddddddd</h1>");
%>
 
<script type="text/javascript">
    var tree;
    function treeInit() {
        tree = new YAHOO.widget.TreeView("leftnavigation");
        var root = tree.getRoot();
        <%
        for(String childNode: treeChildren){ %> 
            var tmpNode = new YAHOO.widget.TextNode({
                label: "<font size=2.5><%=childNode%></font>",
                href: "docs_ajaxprocessor.jsp?path=<%=childNode%>",
                expanded: false,
                alt: "fsfsfff"
            }, root);

          //  var tmpNode2 = new YAHOO.widget.TextNode("mylabel1-1", root, false);
        <% } %>
        tree.render();
    }
    treeInit();

</script>
